//过滤非法字符
function filterChar(_str) {
	return _str.replace(/\>/g, "》").replace(/\</g, "《").replace(/\=/g, "＝")
			.replace(/\'/g, "’").replace(/\_/g, "-").replace(/\&/g, "＆");
}
function intNum(id, int) {
	$("#" + id).keyup(
			function() {
				if (event.keyCode != "37" && event.keyCode != "39"
						&& event.keyCode != "96" && event.keyCode != "97"
						&& event.keyCode != "98" && event.keyCode != "99"
						&& event.keyCode != "100" && event.keyCode != "101"
						&& event.keyCode != "102" && event.keyCode != "103"
						&& event.keyCode != "104" && event.keyCode != "105"
						&& event.keyCode != "48" && event.keyCode != "49"
						&& event.keyCode != "50" && event.keyCode != "51"
						&& event.keyCode != "52" && event.keyCode != "53"
						&& event.keyCode != "54" && event.keyCode != "55"
						&& event.keyCode != "56" && event.keyCode != "57"
						&& event.keyCode != "8" && event.keyCode != "46") {
					this.value = this.value.replace(/[^(\d+\.)]/g, '');
					var num = this.value.split(".").length - 1;
					if (num == 0) {
						this.value = this.value.substring(0, int);
					}
					if (num == 1) {
						if (this.value.split(".")[1].length > 2) {
							this.value = this.value.substring(0,
									this.value.length - 1);
						}
					}
					if (num >= 2) {
						this.value = this.value.substring(0,
								this.value.length - 1);
					}
				}
			});
}
// 获取url参数
var LocString = String(window.document.location.href);
function getUrl(str) {
	var rs = new RegExp("(^|)" + str + "=([^\&]*)(\&|$)", "gi").exec(LocString), tmp;
	if (tmp = rs) {
		return tmp[2];
	}
}
// 获取cookie
function getCookie(name) {
	var strCookie = document.cookie;
	var arrCookie = strCookie.split("; ");
	for ( var i = 0; i < arrCookie.length; i++) {
		var arr = arrCookie[i].split("=");
		if (arr[0] == name)
			return arr[1];
	}
	return "";
}
// 验证为身份证号 还是 手机号 还是 其他
function getUserType(searchstr) {
	var regMobile = /^0?1[3|4|5|8][0-9]\d{8}$/;// 手机号正则
	var regIdcard=/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;// 身份证号正则
	var mflag = regMobile.test(searchstr);
	var idflag = regIdcard.test(searchstr);
	if(mflag){
		return "1";
	}
	if(idflag){
		return "2";
	}
	return "3";
}
// 向JQ对象内写入get中参数p的内容
function WriteIntoID(id,p,isdecode){
	var ptext = getUrl(p);
	if(isdecode==1){
		ptext = decodeURI(ptext);
	}else if(isdecode==2){
		ptext = parseFloat(ptext)*100+"%";
	}
	$(id).html(ptext);
}
// 显示分享层
function display_obj(obj,isdis){
	//if(is_weixn()){
	if(1){
		if(isdis){
			$(obj).show();
		}else{
			$(obj).hide();
		}
	}else{
		window.location.href = 'http://www.baidu.com';
	}
}
//根据浏览器判断是否下载
function GoToByWeixin(){
	if(is_weixn()){
		
	}else{
		window.location.href = 'http://www.baidu.com';
	}
}
// 判断是否是微信浏览器
function is_weixn(){
    var ua = navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i)=="micromessenger") {
        return true;
    } else {
        return false;
    }
}